import request from '@/utils/request'

export const getEmplyeListAPI = (params) => {
  return request({ url: '/sys/user', params })
}

export const exportEmployeeAPI = () => {
  return request({ url: '/sys/user/export', responseType: 'blob' })// 使用bolb接受二进制文件流
}
/**
 * 下载员工导入模版
 * **/

export const getExportTemplateAPI = () => {
  return request({
    url: '/sys/user/import/template',
    responseType: 'blob' // 二进制文件流
  })
}

export const uploadExcelAPI = (data) => {
  return request({
    url: '/sys/user/import',
    method: 'post',
    data // form-data类型 因为要上传文件类型
  })
}
/**
 * 删除员工
 * **/

export function delEmployee(id) {
  return request({
    method: 'delete',
    url: `/sys/user/${id}`
  })
}

export function addEmployee(data) {
  return request({
    url: '/sys/user',
    method: 'post',
    data
  })
}
/**
 *  获取员工详情
 * **/

export function getEmployeeDetailAPI(id) {
  return request({
    url: `/sys/user/${id}`
  })
}
export function updateEmployee(data) {
  return request({
    url: `/sys/user/${data.id}`,
    method: 'put',
    data
  })
}
